package backgammon;

import java.awt.Color;

/**
 * <p>Represents a backgammon player.</p>
 * @author Jacob Kwitkoski
 * @version 1.0
 */
public abstract class AbstractPlayer {
    /**
     * <p>The starting number of pips per player.</p>
     */
    private static final int START_PIPS = 167;

    /**
     * <p>The number of pips the player has remaining.</p>
     */
    private int pips;

    /**
     * <p>The color of the player's pieces.</p>
     */
    private Color pieceColor;

    private boolean canBearOff;

    private boolean piecesOnBar;

    /**
     * <p>Creates a player with the starting amount of pips.</p>
     * @param color the color pf the player's pieces.
     */
    public AbstractPlayer(final Color color) {
        pieceColor  = color;
        pips        = START_PIPS;
        canBearOff  = false;
        piecesOnBar = false;
    }

    /**
     * <p>Returns the number of pips.</p>
     * @return the number of pips left.
     */
    public final int getPips() {
        return pips;
    }

    /**
     * <p>Sets the number of pips.</p>
     * @param newPips the new number of pips.
     */
    public final void setPips(final int newPips) {
        pips = newPips;
    }

    /**
     * <p>Changes the pips by the passed value.</p>
     * @param changeBy the amount to change the pips by
     */
    public final void changePips(final int changeBy) {
        pips += changeBy;
    }

    public final boolean canBearOff() {
        return canBearOff;
    }

    public final void setCanBearOff(final boolean newCanBearOff) {
        canBearOff = newCanBearOff;
    }

    public final boolean hasPiecesOnBar() {
        return piecesOnBar;
    }

    public final void setPiecesOnBar(final boolean newPiecesOnBar) {
        piecesOnBar = newPiecesOnBar;
    }
}
